package com.ssy.lingxi.contract.controller;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.contract.model.vo.applyamount.request.*;
import com.ssy.lingxi.contract.model.vo.applyamount.response.ApplyAmountOrderDetailQueryVO;
import com.ssy.lingxi.contract.model.vo.applyamount.response.ApplyAmountOrderQueryVO;
import com.ssy.lingxi.contract.model.vo.applyamount.response.ApplyAmountOrderRecordVO;
import com.ssy.lingxi.contract.model.vo.applyamount.response.ApplyAmountOrderVO;
import com.ssy.lingxi.contract.model.vo.common.request.ContractOrderPageVO;
import com.ssy.lingxi.contract.model.vo.common.response.ContractOrderPageResponse;
import com.ssy.lingxi.contract.model.vo.common.response.PageItemVO;
import com.ssy.lingxi.contract.model.vo.common.response.StatusVO;
import com.ssy.lingxi.contract.service.IApplyAmountOrderDetailService;
import com.ssy.lingxi.contract.service.IApplyAmountOrderRecordService;
import com.ssy.lingxi.contract.service.IApplyAmountOrderService;
import com.ssy.lingxi.contract.service.IStatusService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 合同能力-合同请款
 * @author 伍将
 * @date 2021/02/03
 * @version 2.0.0
 */
@RestController
@RequestMapping("/contract/apply/amount")
public class ApplyAmountOrderController extends BaseController {

    @Resource
    private IApplyAmountOrderService service;

    @Resource
    private IApplyAmountOrderDetailService detailService;

    @Resource
    private IApplyAmountOrderRecordService recordService;

    @Resource
    private IStatusService statusService;

    /**
     * 请款单查询-分页查询请款单
     * @author 伍将
     * @date 2021/3/10
     **/
    @RequestMapping(value = "/pageList", method = RequestMethod.GET)
    public Wrapper<PageData<ApplyAmountOrderQueryVO>> pageList(HttpServletRequest httpRequest, @Valid ApplyAmountOrderPageVO pageVO) {
        return service.pageList(getSysUser(httpRequest), pageVO);
    }

    /**
     * 请款单查询-作废
     * @author 伍将
     * @date 2021/3/10
     **/
    @RequestMapping(value = "/invalid")
    public Wrapper<Void> invalid(HttpServletRequest httpRequest, @RequestBody @Valid ApplyAmountOrderInvalidVO invalidVO) {
        return service.invalid(getSysUser(httpRequest), invalidVO);
    }

    /**
     * 查询请款单详情
     * @author 伍将
     * @date 2021/3/10
     **/
    @RequestMapping(value = "/getDetail", method = RequestMethod.GET)
    public Wrapper<ApplyAmountOrderVO> getDetail(HttpServletRequest httpRequest, Long applyId) {
        return service.getDetail(getSysUser(httpRequest), applyId);
    }

    /**
     * 分页查询请款单明细
     * @author 伍将
     * @date 2021/3/10
     **/
    @RequestMapping(value = "/pageDetailList", method = RequestMethod.GET)
    public Wrapper<PageData<ApplyAmountOrderDetailQueryVO>> pageDetailList(ApplyAmountOrderDetailPageVO pageVO) {
        return detailService.pageList(pageVO);
    }

    /**
     * 分页查询请款单流转记录
     * @author 伍将
     * @date 2021/3/10
     **/
    @RequestMapping(value = "/pageRecordList", method = RequestMethod.GET)
    public Wrapper<PageData<ApplyAmountOrderRecordVO>> pageRecordList(HttpServletRequest httpRequest, @Valid ApplyAmountOrderRecordPageVO pageVO) {
        return recordService.pageList(getSysUser(httpRequest), pageVO);
    }

    /**
     * 待新增请款单-分页查询请款单
     * @author 伍将
     * @date 2021/3/10
     **/
    @RequestMapping(value = "/pageToBeAdd", method = RequestMethod.GET)
    public Wrapper<PageData<ApplyAmountOrderQueryVO>> pageToBeAdd(HttpServletRequest httpRequest, @Valid ApplyAmountOrderCommonPageVO pageVO) {
        return service.pageToBeAdd(getSysUser(httpRequest), pageVO);
    }

    /**
     * 待新增请款单-删除
     * @author 伍将
     * @date 2021/3/10
     **/
    @RequestMapping(value = "/delete")
    public Wrapper<Void> delete(HttpServletRequest httpRequest, @RequestBody @Valid ApplyAmountOrderDeleteVO deleteVO) {
        return service.delete(getSysUser(httpRequest), deleteVO);
    }

    /**
     * 待新增请款单-保存
     * @author 伍将
     * @date 2021/3/11
     **/
    @RequestMapping(value = "/save")
    public Wrapper<Long> save(HttpServletRequest httpRequest, @RequestBody @Valid ApplyAmountOrderSaveVO saveVO) {
        return service.save(getSysUser(httpRequest), saveVO);
    }

    /**
     * 待新增请款单-查询合同单据
     * @author ds
     * @date 2021/4/21
     **/
    @RequestMapping(value = "/contractOrderPageList", method = RequestMethod.GET)
    public Wrapper<PageData<ContractOrderPageResponse>> contractOrderPageList(HttpServletRequest httpRequest, @Valid ContractOrderPageVO pageVO) {
        return service.contractOrderPageList(getSysUser(httpRequest), pageVO);
    }

    /**
     * 待新增请款单-提交审核
     * @author 伍将
     * @date 2021/3/10
     **/
    @RequestMapping(value = "/submitExamine")
    public Wrapper<Void> submitExamine(HttpServletRequest httpRequest, @RequestBody @Valid ApplyAmountOrderSubmitVO submitVO) {
        return service.submitExamine(getSysUser(httpRequest), submitVO);
    }

    /**
     * 待审核请款单(一级)-分页查询请款单
     * @author 伍将
     * @date 2021/3/10
     **/
    @RequestMapping(value = "/pageToBeExamineOne", method = RequestMethod.GET)
    public Wrapper<PageData<ApplyAmountOrderQueryVO>> pageToBeExamineOne(HttpServletRequest httpRequest, @Valid ApplyAmountOrderCommonPageVO pageVO) {
        return service.pageToBeExamineOne(getSysUser(httpRequest), pageVO);
    }

    /**
     * 待审核请款单(一级)-审核请款单
     * @author 伍将
     * @date 2021/3/10
     **/
    @RequestMapping(value = "/examineStepOne")
    public Wrapper<Void> examineStepOne(HttpServletRequest httpRequest, @RequestBody @Valid ApplyAmountOrderExamineVO examineVO) {
        return service.examineStepOne(getSysUser(httpRequest), examineVO);
    }

    /**
     * 待审核请款单(二级)-分页查询请款单
     * @author 伍将
     * @date 2021/3/10
     **/
    @RequestMapping(value = "/pageToBeExamineTwo", method = RequestMethod.GET)
    public Wrapper<PageData<ApplyAmountOrderQueryVO>> pageToBeExamineTwo(HttpServletRequest httpRequest, @Valid ApplyAmountOrderCommonPageVO pageVO) {
        return service.pageToBeExamineTwo(getSysUser(httpRequest), pageVO);
    }

    /**
     * 待审核请款单(二级)-审核请款单
     * @author 伍将
     * @date 2021/3/10
     **/
    @RequestMapping(value = "/examineStepTwo")
    public Wrapper<Void> examineStepTwo(HttpServletRequest httpRequest, @RequestBody @Valid ApplyAmountOrderExamineVO examineVO) {
        return service.examineStepTwo(getSysUser(httpRequest), examineVO);
    }

    /**
     * 待提交请款单-分页查询请款单
     * @author 伍将
     * @date 2021/3/10
     **/
    @RequestMapping(value = "/pageToBeSubmit", method = RequestMethod.GET)
    public Wrapper<PageData<ApplyAmountOrderQueryVO>> pageToBeSubmit(HttpServletRequest httpRequest, @Valid ApplyAmountOrderCommonPageVO pageVO) {
        return service.pageToBeSubmit(getSysUser(httpRequest), pageVO);
    }

    /**
     * 待提交请款单-提交
     * @author 伍将
     * @date 2021/3/10
     **/
    @RequestMapping(value = "/submit")
    public Wrapper<Void> submit(HttpServletRequest httpRequest, @RequestBody @Valid ApplyAmountOrderSubmitVO submitVO) {
        return service.submit(getSysUser(httpRequest), submitVO);
    }

    /**
     * 查询状态列表
     * @author 伍将
     * @date 2021/3/10
     **/
    @Deprecated
    @RequestMapping(value = "/getStatusList", method = RequestMethod.GET)
    public Wrapper<List<PageItemVO>> getStatusList() {
        return service.getStatusList();
    }

    /**
     * 状态查询
     * @author ds
     * @date 2021/5/28
     **/
    @RequestMapping(value = "/status/list", method = RequestMethod.GET)
    public Wrapper<StatusVO> statusList() {
        return statusService.getStatusByApplyAmountOrder();
    }
}
